import 'package:cloud_medicine/components/shop_picture.dart';
import 'package:cloud_medicine/pages/current_order.dart';
import 'package:flutter/material.dart';

class ToStringFixed extends StatelessWidget {
  final num mynum;
  const ToStringFixed({Key key, this.mynum}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Text('差￥${this.mynum.toStringAsFixed(2)}起送',
        style: TextStyle(color: Colors.white));
  }
}

class MyContainer extends StatelessWidget {
  final String shopname;
  final num deliveryFee;
  final num allprice;
  final List cartList;
  final num shopID;
  final ValueChanged clearCart;
  const MyContainer(
      {Key key,
      @required this.shopname,
      @required this.deliveryFee,
      @required this.allprice,
      @required this.cartList,
      @required this.shopID,
      this.clearCart})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      margin: EdgeInsets.only(left: 38),
      width: 70,
      child: RaisedButton(
        color: Colors.yellow[700],
        shape: StadiumBorder(),
        child: Text(
          '提交',
          style: TextStyle(
              color: Colors.white, fontSize: 16, fontWeight: FontWeight.w500),
        ),
        onPressed: () {
          Navigator.of(context).push(MaterialPageRoute(
              builder: (context) => CurrentOrder(
                  allprice: this.allprice,
                  cartList: this.cartList,
                  deliveryFee: this.deliveryFee,
                  shopname: this.shopname,
                  shopID: this.shopID,
                  clearCart: (value) => this.clearCart(this.shopID))));
        },
      ),
    );
  }
}

class MedicineShow extends StatelessWidget {
  final imgUrl;
  final name;
  final number;
  final price;
  const MedicineShow(
      {Key key,
      @required this.imgUrl,
      @required this.name,
      @required this.number,
      @required this.price})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
        margin: EdgeInsets.only(top: 15),
        decoration: BoxDecoration(color: Colors.white),
        child: Column(children: <Widget>[
          SizedBox(
              height: 100,
              width: 150,
              child: ShopDetailImg(
                boxFit: BoxFit.contain,
                imgUrl: this.imgUrl,
              )),
          Container(
              child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: <Widget>[
                Text(this.name,
                    style:
                        TextStyle(fontSize: 17, fontWeight: FontWeight.w600)),
                Text('月售：${this.number}'),
                Text('￥${this.price}', style: TextStyle(color: Colors.red))
              ]))
        ]));
  }
}
